package com.panopset.gui.container;

import static java.awt.Color.RED;

import java.awt.Component;
import java.awt.LayoutManager;

import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;

import com.panopset.gui.TPanel;

import static com.panopset.Util.*;
import static com.panopset.gui.LookAndFeel.*;

public class TitledPanel extends TPanel {
    private static final long serialVersionUID = VERSION_SERIAL_NUMBER;

    public final TitledBorder border;

    public void setNormalHighlighting() {
        this.border.setTitleFont(ARIAL_PLAIN_10);
        this.border.setTitleColor(FG_COLOR);
    }

    public void setAlertHighlighting() {
        this.border.setTitleColor(RED);
        this.border.setTitleFont(ARIAL_BOLD_10);
    }

    public TitledPanel(
            String title,
            LayoutManager mgr,
            String toolTipText,
            Component comp) {
        this(title, mgr, toolTipText);
        add(comp);
    }

    public TitledPanel(
            String title,
            LayoutManager mgr,
            String toolTipText) {
        super(mgr);
        LineBorder lb = new LineBorder(LINE_BORDER_COLOR_NORMAL, 1);
        this.border = new TitledBorder(lb, title);
        setBorder(this.border);
        setNormalHighlighting();
        setLayout(mgr);
        setBackground(BG_COLOR);
        setToolTipText(toolTipText);
    }
}
